home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Mac Game Programming Gurus / TricksOfTheMacGameProgrammingGurus.iso / Book Chapters / 06 - Audio / Example Code / Hollywood.h < prev   
Text File  |  1995-03-02  |  5KB  |  151 lines

  1.  
  2. // Hollywood API for use with the Macintosh Sound Manager 3.0
  3. //
  4. // History
  5. //    1/8/95    Created by Steve Hales
  6.  
  7. #ifndef _MAC_SOUND_
  8. #define _MAC_SOUND_
  9.  
  10. #define    kUseAnyVoice        -1                // Pass into any function that requires a voice channel,
  11.                                         // and this will auto determine the voice to use.
  12.  
  13. // Sound callback What events process through custom callback procedures
  14. #define    kSoundDoneNormalStop        1        // at interrupt time, just before final sample
  15. #define    kSoundDoneForcedStop        2        // at interrupt time and non interrupt time, used when sound is stopped
  16.                                         // before playing out
  17. #define    kSoundDoneNoInterrupt        3        // at non interrupt time, sometimes after final sample
  18.  
  19.  
  20. // Feature mask for HY_Setup
  21. #define    kNormal                    0x0        // mono 8 bit
  22. #define    kUseStereo                0x1        // if present then stereo audio is setup
  23. #define    kMaxQuality                0x2        // if present then interpolation is enabled, and drop sampling disabled
  24.  
  25. // mask for stereo positioning
  26. #define    kFullLeft                    (-0x100)
  27. #define    kMiddle                    0x0
  28. #define    kFullRight                    0x100
  29.  
  30. #define MakeVolume(left, right)    ((long)(((right) << 16L) | (long)(left)))
  31.  
  32. // Types
  33. typedef void (*CustomCallbackProc)(short int voiceNumber, short int what, long userData);
  34. typedef Handle SndReference;
  35.  
  36. struct SoundVolume
  37. {
  38.     short int    right;        // high 16 bits
  39.     short int    left;            // low 16 bits
  40. };
  41. typedef struct SoundVolume SoundVolume;
  42.  
  43.  
  44. // Audio Sample Data Format. (ASDF)
  45. // Support for 8, 16 bit data, mono and stereo. Can be extended for multi channel beyond 2 channels, but
  46. // not required at the moment.
  47. //
  48. //    DATA BLOCK
  49. //        8 bit mono data
  50. //            ZZZZZZZ…
  51. //                Z = signed 8 bit data
  52. //
  53. //        16 bit mono data
  54. //            WWWWW…
  55. //                W = signed 16 bit data
  56. //
  57. //        8 bit stereo data
  58. //            ZXZXZXZX…
  59. //                Z = signed 8 bit data for left channel, X = signed 8 bit data for right channel.
  60. //
  61. //        16 bit stereo data
  62. //            WQWQWQ…
  63. //                W = signed 16 bit data for left channel, Q = signed 16 bit data for right channel.
  64. //
  65.  
  66.  
  67.  
  68. Boolean            HY_Is16BitAvailable(void);
  69. Boolean            HY_IsStereoAvailable(void);
  70.  
  71. OSErr            HY_Setup(short int featureMask, short int maxVoices);
  72.  
  73. OSErr            HY_Cleanup(void);
  74.  
  75. Boolean            HY_Active(void);
  76.  
  77. void                HY_RegisterThisSound(SndReference theSound);
  78. SndReference        HY_GetSoundResource(short int resourceID);
  79. void                HY_UnregisterSoundResource(SndReference theSound);
  80. void                HY_UnregisterAllSoundResources(void);
  81.  
  82. OSErr            HY_PlaySoundHandle(    short int voiceNumber, 
  83.                                     SndReference theSound,
  84.                                     CustomCallbackProc callbackProc,    
  85.                                     long userData, 
  86.                                     Boolean killSound);
  87.  
  88. OSErr            HY_PlaySample(    short int voiceNumber,
  89.                                 void *pSample,
  90.                                 long length,
  91.                                 UnsignedFixed rate,
  92.                                 short dataBitSize,
  93.                                 short channelSize,
  94.                                 CustomCallbackProc callbackProc,
  95.                                 long userData,
  96.                                 Boolean killSound);
  97.  
  98. Boolean            HY_IsVoiceEmpty(short int voiceNumber);
  99.  
  100. void                HY_StopSample(short int voiceNumber);
  101.  
  102. void                HY_SetRate(short int voiceNumber, UnsignedFixed newRate);
  103. UnsignedFixed        HY_GetRate(short int voiceNumber);
  104.  
  105. void                HY_SetVolume(short int voiceNumber, SoundVolume newVolume);
  106. SoundVolume        HY_GetVolume(short int voiceNumber);
  107. void                HY_SetStereoPosition(short int voiceNumber, short positionMask);
  108. short            HY_GetStereoPosition(short int voiceNumber);
  109.  
  110. void                HY_ServiceTasks(void);
  111.  
  112. OSErr            HY_PauseHardware(void);
  113. OSErr            HY_ResumeHardware(void);
  114.  
  115. void                HY_SetSoundVBCallBack(void (*theProc)(void));
  116.  
  117. OSErr            HY_StartFilePlay(    short int voiceNumber, 
  118.                                 FSSpec *pFile, 
  119.                                 CustomCallbackProc customCallback,    
  120.                                 long userData,
  121.                                 long bufferSize,
  122.                                 Boolean killSound);
  123.  
  124. Handle            HY_GetMACESound(    CmpSoundHeaderPtr pSndBuffer, 
  125.                                 Ptr *pWave, 
  126.                                 long *length, 
  127.                                 long *loopstart, 
  128.                                 long *loopend, 
  129.                                 long *rate);
  130.  
  131. OSErr            HY_GetSoundResourceInformation(    Handle theSnd, long *pLoopStart, long *pLoopEnd, 
  132.                                             long *pSampleOffsetStart, long *pTotalSize, short *pBaseKey,
  133.                                             short int *pNumChannels, short int *pBitSize,
  134.                                             UnsignedFixed *pRate,
  135.                                             short int *pCompressionType);
  136.  
  137. Handle            HY_CreateSndResourceFromPtr(Ptr pSample, long dataLength, UnsignedFixed sampleRate, 
  138.                                         short bitSize, short numChannels,
  139.                                         short int baseFreq);
  140.  
  141. OSErr            HY_CreateAIFFFileFromPtr(FSSpec *pFile, Ptr pSample, long dataLength, UnsignedFixed sampleRate, 
  142.                                         short bitSize, short numChannels);
  143.  
  144. Handle            HY_CreateMACESndResourceFromPtr(short maceType, Ptr pSample, long dataLength, 
  145.                                         UnsignedFixed sampleRate, 
  146.                                         short bitSize, short numChannels,
  147.                                         short int baseFreq);
  148.  
  149.  
  150. #endif _MAC_SOUND_
  151.